<ul id="user_menu">
  <li<% if controller.controller_name == 'root' && controller.action_name == 'home' %> class="active"<% end %>><%= link_to    "Home",     :controller => 'root',    :action => 'home' %></li>
  <li<% if controller.controller_name == 'project' %> class="active"<% end %>><%= link_to "Projects", :controller => 'project', :action => 'list', :id => nil %></li>
  <li<% if controller.controller_name == 'user' %> class="active"<% end %>><%= link_to    "Users",    :controller => 'user',    :action => 'list' %></li>
  <li<% if controller.controller_name == 'root' && controller.action_name == 'search' %> class="active"<% end %>><%= link_to 'Search', :controller => 'root', :action => 'search' %></li>
  <li><a href="/search?subject=&project=&requestor=&owner=1&status=&priority=&time_worked=&do=Search">My taks</a></li>
  <li style="float: right"><%= render :partial => 'layouts/quick_task_creation' %></li>
</ul>

<ul id="secondary_menu"> 
  <% if controller.controller_name == 'task' %>
    <% if controller.action_name == 'show' %> 
      <li><%= link_to "Edit task", :controller => 'task', :action => 'edit',        :id => @task.task_id %></li>
      <li><%= link_to "Comment",   :controller => 'task', :action => 'add_comment', :id => @task.task_id %></li>
      <% if @task.owner != session[:user].user_id %>
        <% if @task.owner ==  nil %>
          <li><%= link_to "Take", :controller => 'task', :action => 'take', :id => @task.task_id %></li>
	<% else %>
        <li><%= link_to "Steal", :controller => 'task', :action => 'steal', :id => @task.task_id %></li>
	<% end %>
      <% end %>
      <% if @task.status.name != 'closed' %>
        <li><%= link_to "Close", :controller => 'task', :action => 'close', :id => @task.task_id %></li>
      <% end %>
    <% end %>
  <% end %>

  <% if controller.controller_name == 'user' %>
    <% if session[:user].rights == 'ManageAll' %>
      <li><%= link_to "New User", :controller => 'user', :action => 'add' %></li>
    <% end %>
    <% if controller.action_name == 'show' %>
      <% if session[:user].rights == 'ManageAll' %>
        <li><%= link_to "Edit User", :controller => 'user', :action => 'edit', :id => @user.user_id %></li>
      <% end %>	
      <% if session[:user].rights != 'ManageTasks' %>
          <li><%= link_to "Assign Projects", :controller => 'user', :action => 'projects', :id => @user.user_id %></li>
      <% end %>
    <% end %>
  <% end %>

  <% if controller.controller_name == 'project' %>
    <% if controller.action_name == 'tasks' %>
        <li><%= link_to "Add New task", :controller => 'task', :action => 'add', :id => @project.project_id %></li>
    <% end %>
    <% if session[:user].rights != 'ManageTasks' %>
        <li><%= link_to "Add New Project", :controller => 'project', :action => 'add' %></li>
    <% end %>
    <% if controller.action_name == 'list' %>
      <li><%= link_to "Closed projects", :controller => 'project', :action => 'list', :id => 'closed' %></li>
    <% end %>
    <% if controller.action_name == 'show' %>
      <% if session[:user].rights != 'ManageTasks' %>
          <li><%= link_to "Edit project", { :controller => "project", :action => "edit", :id => @project.project_id } %></li>
      <% end %>
      <li><%= link_to "Add comment", { :controller => "project", :action => "add_comment", :id => @project.project_id } %></li>
      <li><%= link_to "Add task", { :controller => "task", :action => "add", :id => @project.project_id } %></li>
      <li><%= link_to "Tasks", { :controller => "project", :action => "tasks", :id => @project.project_id } %></li>
    <% end %>
  <% end %>
</ul>
